package com.douma._2022_7_7;

import java.util.Scanner;

/**
 * 抖码算法，让算法学习变的简单有趣
 *
 * @作者 : 老汤
 */
public class 字符串比较 {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        String s1 = scanner.nextLine();
        String s2 = scanner.nextLine();

        int v = scanner.nextInt();
        int res = Integer.MIN_VALUE;

        // 使用滑动窗口实现
        // 对于滑动窗口请学习课程 B【刷题篇第 12 天：滑动窗口】 第 1 节到第 15 节
        // 链接：https://appvpmptkl94774.pc.xiaoe-tech.com/detail/p_6236dc2fe4b09dda124fcb43/6
        int left = 0, right = 0;
        int totalAbsDiff = 0;
        while (right < s1.length()) {
            char c1 = s1.charAt(right);
            char c2 = s2.charAt(right);

            totalAbsDiff += Math.abs(c1 - c2);

            while (totalAbsDiff > v) {
                c1 = s1.charAt(left);
                c2 = s2.charAt(left);
                totalAbsDiff -= Math.abs(c1 - c2);
                left++;
            }

            res = Math.max(res, right - left + 1);
            right++;
        }

        System.out.println(res);
    }
}
